<?php 
$querydetail=mysql_query("SELECT p.IDProject, p.NameProject, p.Description,DATE_FORMAT(p.DateStart,'%Y-%m-%d') as DateStart, p.DateComplete, p.IDManager, p.`Status`, e.FullName,p.IDView FROM pr_project p,employee e WHERE p.IDProject='".$id."' and p.IDManager = e.IDEmployee LIMIT 1");
$queryLstMember=mysql_query("SELECT c.IDComposition, c.IDEmployee, c.IDProject, c.Position, c.Status, e.UserName, e.FullName, e.Position as PositionEmp,c.REmail FROM pr_composition c, employee e WHERE c.IDProject = '$id' AND c.IDEmployee = e.IDEmployee and c.`Status` = 0 and e.State = 1 ");
$page = 1;
if(array_key_exists("page",$_GET))
    $page  = $_GET['page'];
$_SESSION['projectinfo']=array();
$mtrangthai=array($l_status_project_no,$l_status_project_done);
?>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="admin/attach/js/webtoolkit.aim.js"></script>
<script type="text/javascript" src="admin/attach/js/myattach.js"></script>
<link href="admin/attach/css/myattach.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
$(function() {
	$("#dialog-message").dialog({
		autoOpen : false,
		modal : true,
		buttons : {
			<?=$l_close?> : function() {
				$(this).dialog("close");
			}
		}
	});
});
function startCallback() {
	$('#attachloading').append ('<?=$l_uploading?>');
	return true;
}
</script>
<script type="text/javascript" src="js/jquery-1.8.2.js"></script>
<link rel="stylesheet" type="text/css" href="css/jquery-ui.css" />
<script type="text/javascript" src="js/jquery-ui.js"></script>
<script type="text/javascript" src="admin/ckeditor_351/ckeditor.js"></script>
<script type="text/javascript" src="admin/ckfinder/ckfinder.js"></script>
<style>
.cke_contents {
	height: 250px !important;
}
a[title="Browse Server"]{
	display:none !important;
}
a[title="Duyệt trên máy chủ"]{
	display:none !important;
}
a[title="서버 보기"]{
	display:none !important;
}
a[title="Link"]{
	display:none !important;
}
a[title="Liên kết"]{
	display:none !important;
}
a[title="링크"]{
	display:none !important;
}
a[title="Advanced"]{
	display:none !important;
}
a[title="Tab mở rộng"]{
	display:none !important;
}
a[title="자세히"]{
	display:none !important;
}
tr td.cke_bottom{
	display:none !important;
}
</style>
<script type="text/javascript">
	$(document).ready(function(){
		$('.divinvi:not(:last)').hide();
		$('.divinvi:last').show();
		$('#accordion-js').find('.caption').click(function(){
			$(this).next().slideToggle();
		});
		bindEventAfterAjax();
	}); 

	function cancelAddErr(thamso){
		var link = "#"+thamso;
		$(link).slideToggle();
		document.getElementById('addnewerror').style.display = 'visible';
		document.getElementById('update').style.visibility='hidden';
		document.getElementById('update').style.display='none';
		document.getElementById('addnewerror').style.display = 'inline';
		doctitle = document.getElementById('titleerror');
		 doctitle.style.backgroundColor = "#"+mycolor1;
		CKEDITOR.instances.ncontent.setData('');
		$("#formadderror\\:adderror").htmlarea();
	}
	
	function bindEventAfterAjax(){
		$("#report tr:not(#mo):even").addClass("odd");
	    $("#report tr:not(.odd):not(#mo)").hide();
	    $("#report tr:last-child").show();
	}
	
	function showthemcommand(ele){
		$(ele).parent().parent().parent().find("#themcommand").toggle();	
	}

	function closethemcommand(ele){
		$(ele).parent().parent().toggle();	
	}
	
	function closeCommand(){
		$("#report tr.odd:not(#mo)").show();
		$("#report tr:not(.odd):not(#mo)").hide();
	}
	
	function javas(ele){
		alert($(ele).parent().find("#ajaxok"))
		$(ele).parent().find("#ajaxok").val("sdfsd");
	}
	
	function javass(ele){
		alert(ele);
		alert(ele.parentNode)
		alert(ele.parentNode.getElementsByTagName("input"));
		x = ele.parentNode.getElementsByTagName("input");
		for (i=0;i<x.length;i++)
		{	
			if (x[i].getAttribute("id")=='ajaxok'){
				x[i].value='luan';
				break;
			}
		}
	}

	function waiting_addnewfeature(){
		var gt=document.getElementById("titleerror").value;
		if(gt!=""){
			document.getElementById("troioiwaiting").style.display="block";
			document.getElementById("troioi").style.display="none";
			document.body.style.cursor = 'wait';
		}
	}

	function showcomment_newfunction(vitri,idnf){
		$('#adderror').slideUp();
		//document.getElementById('idtestproject').value="";
		var vidviewpro=document.getElementById("vidviewpro").value;
		var lastview=document.getElementById("nf_lastshowdetail").value;
		if(lastview!=""){
			document.getElementById("nf_lastshowdetail").value=vitri;
			$.ajax({url:"admin/project/nf_aj_hidedetail_newfeature.php",data:{vitri:lastview,vidviewpro:vidviewpro},success:function(rshideshowcomment){
				$("#idviewnewfeature"+lastview).html(rshideshowcomment);
				showdetailcomment_newfunction(vitri,idnf,vidviewpro);
			}});
		}else{
			document.getElementById("nf_lastshowdetail").value=vitri;
			showdetailcomment_newfunction(vitri,idnf,vidviewpro);
		}
	}

	function showdetailcomment_newfunction(vitri,idnf,vidviewpro){
		$.ajax({url:"admin/project/nf_aj_showcomment_newfeature.php",data:{vitri:vitri,idnf:idnf,vidviewpro:vidviewpro},success:function(rsshowcomment){
			$("#idviewnewfeature"+vitri).html(rsshowcomment);
		}});
	}

	function close_showdetail_newfeature(vitri,vidviewpro){
		document.getElementById("nf_lastshowdetail").value="";
		$.ajax({url:"admin/project/nf_aj_hidedetail_newfeature.php",data:{vitri:vitri,vidviewpro:vidviewpro},success:function(rsclosedetail){
			$("#idviewnewfeature"+vitri).html(rsclosedetail);
		}});
	}

	function show_addcomment_newfeature(vitri){
		document.getElementById("idnf_showaddcomment"+vitri).style.display="block";
		document.getElementById("titlecomment"+vitri).value="";
		document.getElementById("titlecomment"+vitri).focus();
	}
	
	function add_comment_newfeature(vitri,idnf,vidviewpro,ele){
		var titlecomment=document.getElementById("titlecomment"+vitri).value;
		if(titlecomment!=""){
			$.ajax({url:"admin/project/nf_aj_addcontentcomment_newfeature.php",data:{vitri:vitri,idnf:idnf,titlecomment:titlecomment},success:function(rsshowaddcomment){
				$("#idnf_showallcomment"+vitri).html(rsshowaddcomment);
				closethemcommand(ele);
			}});
		}else{
			alert("Bạn chưa nhập dữ liệu");
			document.getElementById("titlecomment"+vitri).focus();
		}
	}

	function update_newfeature(id){
		$('#adderror').slideUp();
		$.ajax({url:"admin/project/nf_aj_showupdate_newfeature.php",data:{nfid:id},success:function(rsshowfind){
			var title = $(rsshowfind).find('#title').html();
			var content = $(rsshowfind).find('#content').html();
			document.getElementById('idtestproject').value=id;
			document.getElementById('addnewerror').style.display = 'none';
			document.getElementById('update').style.visibility='visible';
			document.getElementById('update').style.display = 'inline';
			CKEDITOR.instances['ncontent'].setData(content);
			document.getElementById('titleerror').value=title;
			$('#adderror').slideDown();
			$('#titleerror').focus();
			$('#titleerror').select();
		}});
	}
</script>
<script type="text/javascript">
$(document).ready(function() {
	  var editor = CKEDITOR.replace("ncontent",{language:"<?php $lang_current = $_SESSION['lang'];
if (isset($lang_current)) {
	if ($lang_current=='VN'){
		echo 'vi';
	}else if ($lang_current=='KR') {
		echo 'ko';
	}else{
		echo 'en';
	}
}else{
	echo 'en';
} ?>", height:'100%', width:'100%'});
		    CKFinder.setupCKEditor(editor, 'admin/ckfinder') ;
	});
</script>
<div id="contains" style="background-color: #edf4f7;">
<div class="title"></div>
<div class="main_content" id="accordion-js">
	<div class="projectInfo">
		<?php while ($row=mysql_fetch_array($querydetail)){ 
			$idmanager = $row['IDManager'];
			$_SESSION['projectinfo']['idviewpro']=$row['IDView'];
			$_SESSION['projectinfo']['ngaybatdau']=$row['DateStart'];
		?>
		<input type="hidden" id="vidviewpro" value="<?=$row['IDView']?>" />
		<span class="caption"><?php echo $l_project?> : <i><?php echo $row['NameProject']?>
		</i> </span><?php $_SESSION['projectinfo']['namepro_temp']=$row['NameProject'];?>
		<div class="divinvi" style="display: none">
			<table width="100%" cellspacing="5" cellpadding="0">
				<tr>
					<td width="150">- <?php echo $l_start_date?> :</td>
					<td class="underline"><?php echo $row[DateStart]?></td>
				</tr>
				<tr>
					<td width="150">- <?php echo $l_manager?> :</td>					
					<td class="underline"><?php $_SESSION['projectinfo']['nguoiquanly']=$row['FullName']; echo  $row['FullName'];?>
					</td>
				</tr>
				<tr>
					<td width="150">- <?php echo $l_status?> :</td>
					<td class="underline"><?php 
						$_SESSION['projectinfo']['trangthai'] = $mtrangthai[$row['Status']];
						echo $mtrangthai[$row['Status']];
					?>
					</td>
				</tr>
				<tr>
					<td width="150">- <?php echo $l_description?> :</td>
					<td class="underline"><?php echo $row['Description']?></td>
				</tr>
			</table>
		</div>
	</div>
	<?php }?>
	<div class="teamPro">
		<a class="caption"><?php echo $l_listmember?> </a>
		<div class="divinvi" style="display: none">
			<table cellspacing="3" width="100%" style="margin-bottom: 20px" class="listCom">
				<tr>
					<td class="titleComp"><?php echo $l_tester_team?></td>
					<td class="titleComp"><?php echo $l_coder_team?></td>
				</tr>
				<tr>
					<?php 
					$row_array = array();
					$index = 0;
					$mangtester='';
					while ($row = mysql_fetch_array($queryLstMember)){
						$row_array[$index][0] = $row['IDEmployee'];
						$row_array[$index][1] = $row['Position'];
						$row_array[$index][2] = $row['FullName'];
						$row_array[$index][3] = $row['Status'];
						if($row['Position']==0 && $row['REmail']==1){
							if($mangtester==''){
								$mangtester=$row['IDEmployee'];
							}else{
								$mangtester .=",".$row['IDEmployee'];
							}
						}
						$index += 1;
					}
					$_SESSION['mangtester']=$mangtester;
					?>
					<td style="vertical-align: top">
						<ul class="composition">
						<?php 
						foreach ($row_array as $row){
						if(($row[0]==$_SESSION['IDEmployee']) && ($row[1]==0)){
							$_SESSION['postest']=1;
						}
						if($row[1]==0){?>
							<li class="itemCom"><?php echo $row[2];?></li>
							<?php }
						} ?>
						</ul>
					</td>
					<td style="vertical-align: top">
						<ul class="composition">
						<?php
						foreach ($row_array as $rowCoder){
						 if($rowCoder[1]==1){?>
							<li class="itemCom"><?php echo $rowCoder[2];?></li>
							<?php } 
						 }?>
						</ul>
					</td>
				</tr>
			</table>
			<div align="right" style="margin-top:10px">
			<a href="project_admin.php?content=admin/project/updatecomposition.php&id=<?=$id?>"><span class="buttonProject" style="padding: 5px; border:1px solid #999"><?=$l_update?></span></a>
			</div>
		</div>
	</div>
	<div class="newError" id="ajaxedittitletestpro">
		<div style="display:none; text-align:center; width:100%; font-weight: bold; color: green;" id="troioiwaiting">
			<img alt="" src="images/loading1.gif" style="vertical-align: middle;" /><span style="background:none;color:red;text-decoration:blink;font-size:14px;"> => </span><?php echo $l_waiting_newfeature;?>
		</div>
		<div id="troioi" style="width:100%; display:block" >
			<a class="caption"><?php echo $l_themtinhnang?> </a>
			<div class="rf-p divinvi" style="width: 100%; display:none" id="adderror">
				<form action="admin/project/nf_process_addfeature.php" method="get" name="formadderror" id="formadderror" onsubmit="if($('#titleerror').val()==''){$('#titleerror').focus();return false;}else{return true;}">
				<div class="rf-p-b" >
					 <input type="hidden" id="vidpro" name='id' value="<?=$id?>" />
					 <input type="hidden" name='page' value="<?=$page?>" id="page"/>
					 <input type="hidden" name='tab' value="<?=$tab?>" id="tab"/>
					  <input type="hidden" name='idtestproject' id="idtestproject"/>
						 <span style="display: block; text-align: left"><?php echo $l_title?>:</span> 
						 <input type="text" class="intext" style="color: #424242;" name="titleerror" id="titleerror" />
						 <input type="hidden" class="intext" style="color: #424242;background-color: #FFFFB0" value='FFFFB0' name="titleerrorhidden" id="titleerrorhidden" />
						 <br/>
						 <span style="display: block; text-align: left"><?php echo $l_content?>: </span>
						 <textarea rows="" cols="" id="ncontent" class="ncontent" name="ncontent" style="width: 100%"></textarea>
						 <table width="100%">
						  <tr> 
							  <td style="text-align:left"> 
							  </td> 
							  <td style="text-align:right" valign="top" > 
								  <input class="buttonProject" onclick="waiting_addnewfeature()" type="submit" style="margin: 5px 0;" id="addnewerror" name="addnewerror" value="<?=$l_add?>" />
							      <input class="buttonProject"  type="submit" style="margin: 5px 0;visibility: hidden;display: none;" id="update" name="update" value="<?=$l_update?>" />
								  <input class="buttonProject"  type="reset" onclick="return cancelAddErr('adderror');$('#formadderror:adderror').value='';" style="margin: 5px 0;" value="<?php echo $l_cancel?>" />
							  </td> 
						  </tr>
						</table>
					<div style="text-align: right">
					</div>
				</div>
				</form>	
			</div>
		</div>
	</div>
	<div style="margin-top: 10px; width: 100%;" id="aaa"><?php include 'include_new_features.php';?></div>
</div>
</div>
